package com.utils;


import android.support.v4.view.ViewPager;
import android.view.View;
import com.Adapters.TabsPagerAdapter;
import com.shareup.R;


public class PagerUtil {

    public static final int ACTIVITY_LOGIN = 0;

    public static final int ACTIVITY_MAIN = -1;

    public static final String FRAGMENT_EXPLORE = "Explorar";

    public static final String FRAGMENT_FAVORITE = "Favoritos";

    public static final String FRAGMENT_FOLLOWERS = "Seguidores";

    public static String FRAGMENT_MINE = "";

    public static String FRAGMENT_NEWS = "";

    public static final String FRAGMENT_PROFILE = "Perfil";

    public static final String FRAGMENT_TAGS = "Tags";

    public static View PostItemPictureView;

    public static View PostItemTextView;

    private ViewPager pager;

    private TabsPagerAdapter pagerAdapter;

    public PagerUtil(TabsPagerAdapter pagerAdapter, ViewPager pager) {

        super();
        this.pagerAdapter = pagerAdapter;
        this.pager = pager;
        String[] menu = pager.getResources().getStringArray(R.array.array_slidingmenu);
        FRAGMENT_NEWS = menu[0];
        FRAGMENT_MINE = pager.getResources().getString(R.string.tab_my_pictures);
    }

    // -----------------------------------------------------------------------------
    // Here's what the app should do to add a view to the ViewPager.
    public void addView(View newPage) {

        int pageIndex = pagerAdapter.addView(newPage);
        // You might want to make "newPage" the currently displayed page:
        pager.setCurrentItem(pageIndex, true);
    }

    // -----------------------------------------------------------------------------
    // Here's what the app should do to get the currently displayed page.
    public View getCurrentPage() {

        return pagerAdapter.getView(pager.getCurrentItem());
    }

    // -----------------------------------------------------------------------------
    // Here's what the app should do to remove a view from the ViewPager.
    public void removeView(View defunctPage) {

        int pageIndex = pagerAdapter.removeView(pager, defunctPage);
        // You might want to choose what page to display, if the current page
        // was
        // "defunctPage".
        if (pageIndex == pagerAdapter.getCount())
            pageIndex--;
        pager.setCurrentItem(pageIndex);
    }

    // -----------------------------------------------------------------------------
    // Here's what the app should do to set the currently displayed page.
    // "pageToShow" must
    // currently be in the adapter, or this will crash.
    public void setCurrentPage(View pageToShow) {

        pager.setCurrentItem(pagerAdapter.getItemPosition(pageToShow), true);
    }
}
